{extend name="admin@public/main"}
{block name="buttons"}
{if hasAuth('admin/auth/add')}
<button class = "btn btn-sm btn-outline-primary" data-action="dialog" data-action-url="{:url('admin/auth/add')}" data-dialog-title="新增权限">新增权限</button>
{/if}
{/block}
{block name="content"}
<form class = "data-search-form" method="get">
    <table class = "table">
        <thead>
        <tr class = "title">
            <th>名称</th>
            <th>状态</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        <tr>
            <th>
                <input type="text" name = "name" class = "form-control-plaintext search-input" value = "{$where.name|default=''}" placeholder="请输入搜索的权限名"/>
            </th>
            <th>
                <select name = "status" class = "form-control-plaintext search-input">
                    <option value = ""></option>
                    <option value = "1" {if condition="isset($where.status) and $where.status eq 1"}selected{/if}>启用</option>
                    <option value = "2" {if condition="isset($where.status) and $where.status eq 2"}selected{/if}>禁用</option>
                </select>
            </th>
            <th>
                <input type="text" name ="remark" class = "form-control-plaintext search-input" value = "{$where.remark|default=''}" placeholder="请输入搜索的备注"/>
            </th>
            <th></th>
        </tr>
        </thead>
        {php}$user_status = ['','启用','禁用'];{/php}
        <tbody>
        {if empty($list)}
        <tr>
            <td colspan = "4" class = "empty-list"><span class = "glyphicon glyphicon-inbox"></span>没有任何记录</td>
        </tr>
        {else}
        {volist name="list" id="vo"}
        <tr>
            <td>{$vo.name|default=''}</td>

            <td>{$user_status[$vo.status]}</td>
            <td>{$vo.remark|default=''}</td>
            <td>
                {if hasAuth('admin/auth/edit')}
                <span class="text-explode">|</span>
                <a class = "user-option" data-action = "dialog" data-action-url="{:url('admin/auth/edit',['id'=>$vo.id])}"  data-dialog-title="编辑权限">编辑</a>
                {/if}
                {if hasAuth('admin/auth/auth')}
                <span class = "text-explode">|</span>
                <a class = "user-option" data-action = "dialog" data-action-url="{:url('admin/auth/auth',['id'=>$vo.id])}" data-dialog-title="权限授权">授权</a>
                {/if}
                {if hasAuth('admin/auth/forbid')}
                <span class="text-explode">|</span>
                {if condition="$vo.status eq 1"}
                <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/auth/forbid')}"
                   data-action-params = '{"id":{$vo.id},"field":"status","value":2}' data-action-method = "post">禁用</a>
                {else}
                <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/auth/forbid')}"
                   data-action-params = '{"id":{$vo.id},"field":"status","value":1}' data-action-method = "post">启用</a>
                {/if}
                {/if}
                {if hasAuth('admin/auth/del')}
                <span class="text-explode">|</span>
                <a class = "user-option" data-action = "ajax" data-action-url="{:url('admin/auth/del')}"
                   data-action-params = '{"id":{$vo.id},"field":"delete"}' data-action-ask = "是否确定删除权限:{$vo.name}" data-action-method = "post">删除</a>
                {/if}

            </td>
        </tr>
        {/volist}
        {/if}
        </tbody>
    </table>
    {$list->render()}
</form>
{/block}